<?php
	getHeader();
	if (isset($_GET['cid']))
	{
?>
		<script type="text/javascript" src="<?php echo THEMEURL; ?>js/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="<?php echo THEMEURL; ?>js/jquery.masonry.min.js"></script>
		<script type="text/javascript" src="<?php echo THEMEURL; ?>js/jquery.imagesloaded.js"></script>
		<link  type="text/css" rel="stylesheet"  href="<?php echo THEMEURL; ?>waterFall.css" />
		<div id='content'>
			<div class='tabs headTabs'>
				<ul>
					<li><a href='?p=editTeam&do=create&cid=<?php echo $_GET['cid']; ?>' class='tabLink'>创建队伍</a></li>
				</ul>
				<span>参赛队伍</span>
			</div>
<?php
			$comp = compProf::getCompetitionTeamByCid($_GET['cid']);
			if ($comp == 'NO')
			{
?>
				<div class="dataList">
					<span>本比赛暂无参赛队伍</span>
				</div>
		</div>
<?php
			}
			else 
			{
?>
				<script>
  					$(function(){

   					 var $container = $('#container');
  
    				 $container.imagesLoaded( function(){
      				 $container.masonry({
          			 itemSelector : '.box'
      					});
   					 });
 					});
				</script>
				<div id="container" >
					<ul>
<?php
						while ($arr = mysql_fetch_array($comp))
						{
							$leader = userProf::getUserByUid($arr['teamLeaderUid']);
							$album = $leader->getUserAlbum($arr['teamName']);
							$album = mysql_fetch_array($album);
?>							<div class="box">
							<div><p><img src="<?php echo getAlbumFirstImageUrl($album['aid']);?>"></p></div>
							<div><p>队名: <a href='?p=viewTeam&tid={$arr['tid']}'><?php echo $arr['teamName']; ?></a></p></div>
							<div><p>队长: <a href='?p=viewUser&uid=<?php echo $arr['teamLeaderUid']; ?>'><?php echo userProf::getUsernameByUid($arr['teamLeaderUid']); ?></a></p></div>
							<div><p>队员: <?php echo getMemberLink($arr['teamMemberUid']); ?></p></div>
							<div><p>队伍介绍: <?php echo $arr['teamIntroduction']; ?></p></div>
							</div>
<?php
						}
?>
					</ul>
				</div>
		</div>
<?php
			}
	}
	else if (isset($_GET['tid']))
	{
		$team = teamProf::getTeamByTid($_GET['tid']);
?>
		<div id='content'>
			<div class='tabs headTabs'>
				<ul>
<?php
					if (isset($_SESSION['uid']) && $_SESSION['uid'] == $team->leader)
					{
?>
						<li><a href='?p=editTeam&do=invite&tid=<?php echo $team->tid; ?>' class="tabLink">邀请加入</a></li>
<?php
					}
					else 
					{
?>
						<li><a href='?p=editTeam&do=request&tid=<?php echo $team->tid; ?>' class="tabLink">申请加入</a></li>
						<li><a href='?p=editTeam&do=create&cid=<?php echo $_GET['cid'];?>' class='tabLink'>创建队伍</a></li>
<?php
					}
?>
				</ul>
				<span>查看队伍: <?php echo $team->name; ?></span>
			</div>
			<div class='dataList'>
				<ul>
					<li>队长: <a href='?p=viewUser&uid=<?php echo $team->leader; ?>'><?php echo userProf::getUsernameByUid($team->leader); ?></a></li>
					<li>队员: <?php echo getMemberLink($team->member); ?></li>
					<li>队伍介绍: <?php echo $team->introduction; ?></li>
				</ul>
			</div>
		</div>
<?php
	}
	else 
	{
		
	}
	getPanel();
	getFooter();
?>
